/*
 * Created by JFormDesigner on Tue Jul 02 01:01:50 CST 2024
 */

package scct.hys.ui;

import scct.hys.dao.CinemaDao;
import scct.hys.dao.HallDao;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * @author 26984
 */
public class DlgHallAdd extends JDialog {
    int id;
    public DlgHallAdd(Window owner) {
        super(owner);
        initComponents();
        this.id=id;
    }

    private void btnAdd(ActionEvent e) {
        // TODO add your code here
        String movieid= txtName.getText();
        String screensize=txtSize.getText();
        String screentype= txtType.getText();
        String total=txtTotal.getText();
        HallDao hallDao=new HallDao();
        if (hallDao.addHall(movieid,screentype,screensize,total)){
            JOptionPane.showMessageDialog(this,"添加成功");
        }
        this.dispose();


    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents  @formatter:off
        // Generated using JFormDesigner Evaluation license - 韩月生
        label1 = new JLabel();
        txtType = new JTextField();
        label2 = new JLabel();
        txtSize = new JTextField();
        label3 = new JLabel();
        txtTotal = new JTextField();
        btnAdd = new JButton();
        btnCancel = new JButton();
        label4 = new JLabel();
        txtName = new JTextField();

        //======== this ========
        setTitle("\u6dfb\u52a0\u5f71\u5385");
        var contentPane = getContentPane();
        contentPane.setLayout(null);

        //---- label1 ----
        label1.setText("\u5f71\u5385\u7c7b\u578b");
        contentPane.add(label1);
        label1.setBounds(55, 78, 70, label1.getPreferredSize().height);
        contentPane.add(txtType);
        txtType.setBounds(155, 75, 130, 30);

        //---- label2 ----
        label2.setText("\u5f71\u5385\u5c3a\u5bf8");
        contentPane.add(label2);
        label2.setBounds(55, 121, 70, label2.getPreferredSize().height);

        //---- txtSize ----
        txtSize.setText("23.71mX13.32m");
        txtSize.setEditable(false);
        contentPane.add(txtSize);
        txtSize.setBounds(155, 114, 185, 30);

        //---- label3 ----
        label3.setText("\u5f71\u5385\u603b\u4eba\u6570");
        contentPane.add(label3);
        label3.setBounds(55, 164, 70, label3.getPreferredSize().height);
        contentPane.add(txtTotal);
        txtTotal.setBounds(155, 157, 185, 30);

        //---- btnAdd ----
        btnAdd.setText("\u786e\u5b9a\u6dfb\u52a0");
        btnAdd.addActionListener(e -> btnAdd(e));
        contentPane.add(btnAdd);
        btnAdd.setBounds(new Rectangle(new Point(50, 225), btnAdd.getPreferredSize()));

        //---- btnCancel ----
        btnCancel.setText("\u53d6\u6d88");
        contentPane.add(btnCancel);
        btnCancel.setBounds(new Rectangle(new Point(225, 225), btnCancel.getPreferredSize()));

        //---- label4 ----
        label4.setText("\u5f71\u7247\u540d\u5b57");
        contentPane.add(label4);
        label4.setBounds(55, 35, 70, label4.getPreferredSize().height);
        contentPane.add(txtName);
        txtName.setBounds(155, 35, 130, txtName.getPreferredSize().height);

        {
            // compute preferred size
            Dimension preferredSize = new Dimension();
            for(int i = 0; i < contentPane.getComponentCount(); i++) {
                Rectangle bounds = contentPane.getComponent(i).getBounds();
                preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
            }
            Insets insets = contentPane.getInsets();
            preferredSize.width += insets.right;
            preferredSize.height += insets.bottom;
            contentPane.setMinimumSize(preferredSize);
            contentPane.setPreferredSize(preferredSize);
        }
        setSize(400, 300);
        setLocationRelativeTo(null);
        // JFormDesigner - End of component initialization  //GEN-END:initComponents  @formatter:on
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables  @formatter:off
    // Generated using JFormDesigner Evaluation license - 韩月生
    private JLabel label1;
    private JTextField txtType;
    private JLabel label2;
    private JTextField txtSize;
    private JLabel label3;
    private JTextField txtTotal;
    private JButton btnAdd;
    private JButton btnCancel;
    private JLabel label4;
    private JTextField txtName;
    // JFormDesigner - End of variables declaration  //GEN-END:variables  @formatter:on
}
